home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c++
- Subject: Re: const member functions
- Date: Fri, 12 Apr 1996 18:10:51 GMT
- Organization: Netcom
- Message-ID: <316e9bef.157471972@nntp.ix.netcom.com>
- References: <316588E6.7D61@geoplex.com> <4kgs7s$vb4@zk2nws.zko.dec.com>
- NNTP-Posting-Host: ix-dc11-06.ix.netcom.com
- X-NETCOM-Date: Fri Apr 12 1:07:44 PM CDT 1996
- X-Newsreader: Forte Agent .99d/32.182
-
- Alexander Goykhman USG <goykhman@zk3.dec.com> wrote:
-
- > "Jay B. Perry" <jay@geoplex.com> wrote:
- >
- > >class X
- > >{
- > >public: // Public methods
- >
- > > int value( ) const { return _value; }
- > >
- > >private: // Private methods
- > >
- > > int& value( ) { return _value; }
- >
- >
- > I don't see how a compiler could possibly
- > distinguish between:
- >
- > int value()
- >
- > and
- >
- > int& value()
- >
- >
- > IMO, the above is ambiguous and ought to be
- > flagged as such by the compiler.
-
- Non seqitur. The compiler cannot distinquish between
-
- int value()
-
- and
-
- int& value()
-
- and any correct compiler will flag that as an error.
-
- However, that has nothing to do with the code Jay posted where he asks
- the compiler to distinguish between
-
- int value()
-
- and
-
- int& value() const
-
- C++ allows overloading based on whether the class object is const.
-
-
- Michael M Rubenstein
-